package com.sphd.emanu.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.emanu.R;
import com.sphd.emanu.pojo.bank.AccountDetailsBean;
import com.wzutils.TimeUtils;

import java.util.Calendar;
import java.util.List;

/**
 * @Author Hu
 * @Time 2017/7/12 --17:41.
 * @Email 87683202@qq.com
 */
public class DayDetailAdapter extends BaseQuickAdapter<AccountDetailsBean, BaseViewHolder> {
    public DayDetailAdapter(@LayoutRes int layoutResId, @Nullable List<AccountDetailsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AccountDetailsBean item) {

        helper.setVisible(R.id.day_detail_month_day,helper.getLayoutPosition()==0?true:false)
                .setText(R.id.day_detail_month_day, TimeUtils.dateToString(TimeUtils.stringToDate(item.getCreateDate(),TimeUtils.YEAR_MONTH_DAY)
                        ,TimeUtils.YEAR_MONTH_DAY))
                .setText(R.id.day_detail_minus, TimeUtils.getDayAndTime(Calendar.getInstance(),
                        item.getCreateDate())[1])
                .setText(R.id.day_detail_message,item.getAuditorName() + (item.getDebit()
                        == 0 ? item.getCredit() : item.getDebit())
                        + "\n" + item.getSummary())
                .setImageResource(R.id.income_out,item.getDebit()
                        == 0 ?R.mipmap.green_cycler:R.mipmap.red_cycler);

    }
}
